package com.haha.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.Long.library.R;


/**
 * Created by Administrator on 2016/6/20 0020.
 */
public class CustomAlertDialog extends CustomDialog{
    private TextView dialogTitle,dialogMessage;
    private View confirmBtn,cancelBtn;
    private View btnLayout;

    public CustomAlertDialog(Context context) {
        super(context, R.layout.custom_alert_dialog);
        findview();
        initView();
    }

    private void findview(){
        dialogTitle = (TextView)findViewById(R.id.dialog_title);
        dialogMessage = (TextView)findViewById(R.id.dialog_message);
        confirmBtn = findViewById(R.id.confirm_btn);
        cancelBtn = findViewById(R.id.cancel_btn);
        btnLayout = findViewById(R.id.btn_layout);
    }

    private OnCustomDialogClickListener onCustomDialogClickListener;

    public void setOnCustomDialogClickListener(OnCustomDialogClickListener onCustomDialogClickListener){
        this.onCustomDialogClickListener = onCustomDialogClickListener;
    }

    public interface OnCustomDialogClickListener{
        void onConfirmBtnClicked();
        void onCancelBtnClicked();
    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (onCustomDialogClickListener == null)return;
            int i = v.getId();
            if (i == R.id.confirm_btn){
                onCustomDialogClickListener.onConfirmBtnClicked();
                dismiss();
            }else if (i == R.id.cancel_btn){
                onCustomDialogClickListener.onCancelBtnClicked();
                dismiss();
            }
        }
    };

    private void initView(){
        confirmBtn.setOnClickListener(onClickListener);
        cancelBtn.setOnClickListener(onClickListener);
    }



}
